<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color:lightblue;
            margin: auto;
            position:absolute;
            left:0;
            top:0;
            bottom:0;
            right:0;
        }
    </style>
</head>
<body>
<div></div>
<script src="../MyJs.js"></script>
<script>
    var arr=[];
    var oDiv=document.getElementsByTagName("div")[0];
    for(var i=16;i>0;i-=2){
        arr.push(-i,i);
    }
    arr.push(0);
    oDiv.onclick=function(){
        clearInterval(timer);
        var i=0;
        var timer=setInterval(function(){
            oDiv.style.left=parseInt(getStyle(oDiv,"left"))+arr[i++]+"px";
            if(i===arr.length){
                clearInterval(timer);
            }
        },30)
    }
</script>
</body>
</html>